<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="format-detection" content="telephone=no">
<title>我的订单</title>
<link rel="stylesheet" type="text/css" href="{$Think.config.RESOURCEURL}wx_assets/css/product.css?v=2013-11-30">
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/alertMsg.js"></script>
<script type='text/javascript' src='{$Think.config.RESOURCEURL}wx_assets/js/jquery-1.7.1.min.js'></script>
<script type='text/javascript' src='{$Think.config.RESOURCEURL}wx_assets/js/base.js'></script>
<style>abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,fieldset,figure,figcaption,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,small,time,video,legend{display:block;}</style>
<script src="{$Think.config.RESOURCEURL}http://res.wx.qq.com/mmbizwap/en_US/htmledition/js/wxm-core1530d0.js"></script>

</head>
<body id="page_intelOrder" class="myOrderCon">
<div class="center">
    <ul class="myorder">
    	<li class="title mb">
            <span class="none">我的菜单</span>
            <i>
	            <span class="pCount"></span>
	     		<label>
	     		<b>共计：</b>
	     		<b class="duiqi" id="total">{$price}</b>
	     		<b class="duiqi">元</b>
	     		</label>
            </i>
        </li>
       	<volist name="productList" id="product">
	       	<li>
	       		<span class="dishName">{$product.name}</span>
	       		
            	<notempty name="product.fixedPrice">
					<empty name="product.discountedPrice">
						<empty name="product.unitName">
							<i> {$product.fixedPrice}元 </i>
						</empty>
						<notempty name="product.unitName">
							<i> {$product.fixedPrice}元/{$product.unitName} </i>
						</notempty>
					</empty>
					<notempty name="product.discountedPrice">
						<empty name="product.unitName">
							<i>{$product.discountedPrice}元</i>
						</empty>
						<notempty name="product.unitName">
							<i>{$product.discountedPrice}元/{$product.unitName}</i>
						</notempty>
					</notempty>
				</notempty>
               
               <section class="bbox" dishid="{$product.id}" dishname="{$product.name}">
	               <input class="numBox" name="numBox" type="text" value="x {$product.reserveCount}"
	               	discountedprice="{$product.discountedPrice}" fixedprice="{$product.fixedPrice}" readonly="readonly">
               </section>
	        </li>
         </volist>
    </ul>
</div>
<script>
var hrefParamsArray = GetSessionIdFromHref(window.location.search);
hrefParamsArray["userName"]='{$userName}';
function GetSessionIdFromHref(search){
　　	var args = search.substring(1); 
　　	var retval = new Array(); 
	args = args.split("&"); 
		for(var i = 0; i < args.length; i ++){ 
			str = args[i]; 
			var arg = str.split("="); 
			if(arg.length <= 1) continue; 
			
			if(arg[0] == 'params') {
				var params = decodeURIComponent(arg[1]);
				var obj = eval('(' + params + ')');
				retval["id"] = obj.id;
				retval["sid"] = obj.sid;
				retval["type"] = obj.type;
			} else if(arg[0] == 'customerId') {
				retval["customerId"] = arg[1]; 
			}else if(arg[0] == 'userName'){
				retval["userName"] = arg[1]; 
			}
		} 
		return retval; 
}

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
	WeixinJSBridge.call('showOptionMenu');
	});
	
		function report(link, fakeid, action_type){
		    var parse_link = parseUrl(link);
		    if(parse_link == null)
		    {
		      return ;
		    }
		    var query_obj = parseParams( parse_link['query_str'] );
		    query_obj['action_type'] = action_type;
		    query_obj['uin'] = fakeid;
		    var report_url = '/mp/appmsg/show?' + jQuery.param( query_obj );
		    jQuery.ajax({
		      url: report_url,
		      type: 'POST',
		      timeout: 2000
		    })
		 };
		 
		function share_scene(link, scene_type) {
			// Android无法会截取encode的参数，所以改用直接添加参数的方式
			var share_url = link + '&scene=' + scene_type;
			return share_url;
		};

		(function() {
			var desString = '{$productList[0]['name']}';
			if("{$productList[1]['name']}" != ""){
				desString = desString +"\n"+"{$productList[1]['name']}";
			}
			if("{$productList[2]['name']}" != ""){
				desString = desString +"\n"+"{$productList[2]['name']}";
			}
			desString = desString +"\n"+"...";
			
			var titleString = "我在"+'{$sName}'+"点了餐";
			
		//	var search = resetHerf(window.location.search);
			var search = window.location.search;

			var onBridgeReady = function() {
			var baseUrl =  '{$Think.config.SERVER_HOST}';
			var link = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
				+ '&module=product&method=getOrderDetail&params={"id":"' + hrefParamsArray["id"] + '","sid":' + hrefParamsArray["sid"]
				+ ',"isShare":true}#mp.weixin.qq.com';
			link = encodeURI(link);
			
				var appId = '', title = htmlDecode(titleString), desc = htmlDecode(desString),
				imgUrl = encodeURI('{$sPicUrl}'), fakeid = "Mjc2OTgzMTM1", desc = desc || link;
				
				// 发送给好友; 
				WeixinJSBridge.on('menu:share:appmessage', function(argv) {

					WeixinJSBridge.invoke('sendAppMessage', {
						"appid" : appId,
						"img_url" : imgUrl,
						"img_width" : "640",
						"img_height" : "640",
						"link" : share_scene(link, 1),
						"desc" : desc,
						"title" : title
					}, function(res) {
						report(link, fakeid, 1);
					});
				});
				// 分享到朋友圈;
				WeixinJSBridge.on('menu:share:timeline', function(argv) {
					report(link, fakeid, 2);
					WeixinJSBridge.invoke('shareTimeline', {
						"img_url" : imgUrl,
						"img_width" : "640",
						"img_height" : "640",
						"link" : share_scene(link, 2),
						"desc" : desc,
						"title" : title
					}, function(res) {
					});

				});

				// 分享到微博;
				var weiboContent = '';
				WeixinJSBridge.on('menu:share:weibo', function(argv) {

					WeixinJSBridge.invoke('shareWeibo', {
						"content" : title + share_scene(link, 3),
						"url" : share_scene(link, 3)
					}, function(res) {
						report(link, fakeid, 3);
					});
				});
				// 隐藏右上角的选项菜单入口;
				//WeixinJSBridge.call('hideOptionMenu');
			};
			if (document.addEventListener) {
				document.addEventListener('WeixinJSBridgeReady', onBridgeReady,
						false);
			} else if (document.attachEvent) {
				document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
				document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
			}
		})();
	</script>
</body></html>